{% set pypi_name = 'neutron-dynamic-routing' %}
{% set source = fetch_source('https://tarballs.openstack.org/neutron-dynamic-routing/neutron-dynamic-routing-master.tar.gz') %}
{% set upstream_version = upstream_version() %}
{% set rpm_release = '1' %}
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Epoch:          {{ epoch('{{ pypi_name }}') }}
Summary:        OpenStack Neutron Dynamic Routing Service
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/neutron
Source0:        {{ source|basename }}
Source1:        openstack-neutron-bgp-dragent.service
BuildRequires:  openstack-macros
BuildRequires:  {{ py2pkg('neutron') }}
BuildRequires:  {{ py3('pbr') }}
Requires:       python3-{{ pypi_name }} = %{epoch}:%{version}-%{release}
BuildArch:      noarch

%description
Neutron is a virtual network service for Openstack.
This is a dynamic routing service plugin for Openstack Neutron (Networking) service.

%package -n python3-{{ pypi_name }}
Summary:        OpenStack Neutron Dynamic Routing Service - Python module
Group:          Development/Languages/Python
Requires:       {{ py2pkg('neutron') }}
Requires:       {{ py3('SQLAlchemy') }}
Requires:       {{ py3('alembic') }}
Requires:       {{ py3('eventlet') }}
Requires:       {{ py3('httplib2') }}
Requires:       {{ py3('netaddr') }}
Requires:       {{ py3('neutron-lib') }}
Requires:       {{ py3('os-ken') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.db') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('oslo.messaging') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.service') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('six') }}

%description -n   python3-{{ pypi_name }}
Neutron is a virtual network service for Openstack.
This is a dynamic routing service plugin for Openstack Neutron (Networking) service.

This package contains the Neutron Dynamic Routing Python library.

%package bgp-dragent
Summary:        Neutron Dynamic Routing Agent
Requires:       {{ py2name() }} = %{epoch}:%{version}-%{release}
Provides:       {{ py2name('neutron') }}-bgp-dragent = %{epoch}:%{version}-%{release}

%description bgp-dragent
Provides BGP dynamic routing services for Neutron.

%package doc
Summary:        OpenStack Neutron Dynamic Routing Service - Documentation
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-svg2pdfconverter') }}

%description doc
Neutron is a virtual network service for Openstack.
This is a dynamic routing service plugin for Openstack Neutron (Networking) service.

This package contains the documentation.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{upstream_version}}
%py_req_cleanup

%build
%py3_build

# generate html docs
PYTHONPATH=$PWD PBR_VERSION={{ upstream_version }} %sphinx_build --keep-going -b html doc/source doc/build/html
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%py3_install

### configuration files
PYTHONPATH=. oslo-config-generator --config-file etc/oslo-config-generator/bgp_dragent.ini

install -p -D -m 644 etc/bgp_dragent.ini.sample %{buildroot}%{_sysconfdir}/neutron/bgp_dragent.ini

### systemd
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/openstack-neutron-bgp-dragent.service

%post
%systemd_post openstack-neutron-bgp-dragent.service

%preun
%systemd_preun openstack-neutron-bgp-dragent.service

%postun
%systemd_postun_with_restart openstack-neutron-bgp-dragent.service

%files
%license LICENSE
%doc README.rst
%config(noreplace) %{_sysconfdir}/neutron/bgp_dragent.ini

%files -n python3-{{ pypi_name }}
%license LICENSE
%{python3_sitelib}/neutron_dynamic_routing
%{python3_sitelib}/neutron_dynamic_routing-*.egg-info

%files bgp-dragent
%license LICENSE
%{_bindir}/neutron-bgp-dragent
%{_unitdir}/openstack-neutron-bgp-dragent.service

%files doc
%license LICENSE
%doc doc/build/html

%changelog
